﻿using PhotoGallery.Data;
using PhotoGallery.Data.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PhotoGallery.Models
{
    public class BaseModel
    {
        protected string BasePath
        {
            get
            {
                return HttpContext.Current.Server.MapPath("~");
            }
        }

        string owner;
        protected string Owner
        {
            get
            {
                if (String.IsNullOrEmpty(owner))
                {
                    return System.Web.HttpContext.Current.User.Identity.Name;
                }
                else
                {
                    return owner;
                }
            }
            set
            {
                owner = value;
            }
        }

        protected string getAlbumFolder(Album album)
        {
            if (album.FolderName == null || album.FolderName == String.Empty)
            {
                return Settings.AlbumFolder + album.ID + "\\";
            }
            else
            {
                return album.FolderName + "\\";
            }
        }

        protected string getAlbumUrl(Album album)
        {
            if (album.FolderName == String.Empty)
            {
                return "album" + album.ID.ToString() + "/";
            }
            else
            {
                return album.FolderName + "/";
            }
        }

        protected string getAlbumFolder(AlbumInfo album)
        {
            if (album.FolderName == null || album.FolderName == String.Empty)
            {
                return Settings.AlbumFolder + album.ID + "\\";
            }
            else
            {
                return album.FolderName + "\\";
            }
        }

        protected string getAlbumUrl(AlbumInfo album)
        {
            if (album.FolderName == String.Empty)
            {
                return "album" + album.ID.ToString() + "/";
            }
            else
            {
                return album.FolderName + "/";
            }
        }
    }
}